package com.chenyi.leetcode.editor.cn;

import java.util.Arrays;

/**
 * [剑指 Offer 40]最小的k个数
 * @author by chenyi
 * @className ZuiXiaoDeKgeShuLcof
 * @date 2022-08-27 16:39:07
 */
public class ZuiXiaoDeKgeShuLcof{
    public static void main(String[] args) {
        Solution solution = new ZuiXiaoDeKgeShuLcof().new Solution();
        System.out.println(Arrays.toString(solution.getLeastNumbers(new int[]{3, 2, 1}, 2)));
    }
    @SuppressWarnings("AlibabaCommentsMustBeJavadocFormat")
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public int[] getLeastNumbers(int[] arr, int k) {
        int[] minArray = new int[k];
        Arrays.sort(arr);
        for (int i = 0; i < minArray.length; i++) {
            minArray[i] = arr[i];
        }
        return minArray;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}
